
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetCurrentReportingPeriod]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetCurrentReportingPeriod]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/******************************************************************  
* Name:   GetCurrentReportingPeriod  
* Purpose:  Retrieves the current reporting period
*  
* PARAMETERS  
* Name         Description       
* -------------      -------------------------------------------  
* 
******************************************************************/  
  
CREATE Procedure [dbo].[GetCurrentReportingPeriod] 
(
	@COITypeId INT = 1
)
AS  
BEGIN  
  
 SET NOCOUNT ON  
  
 Select Id, ReportingPeriod, COITypeId
 FROM COIReportingPeriods 
 WHERE Id = (SELECT Max(Id) FROM COIReportingPeriods WHERE COITypeId = @COITypeId)  
   
END  

GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF  

  

  
  